package com.southminority.ethnic.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.southminority.ethnic.pojo.MapLocationConfig;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 地图位置配置Mapper
 * 
 * @author SouthMinority
 */
@Mapper
public interface MapLocationConfigMapper extends BaseMapper<MapLocationConfig> {
    
    // 继承MyBatis Plus的BaseMapper，提供基础CRUD能力
    
    /**
     * 查询启用的地图位置配置列表
     */
    @Select("SELECT * FROM map_location_config WHERE is_active = 1 ORDER BY sort_order ASC, id ASC")
    List<MapLocationConfig> selectActiveConfigs();
    
    /**
     * 查询默认的地图位置配置
     */
    @Select("SELECT * FROM map_location_config WHERE is_default = 1 AND is_active = 1 LIMIT 1")
    MapLocationConfig selectDefaultConfig();
    
    /**
     * 根据机构ID查询地图位置配置
     */
    @Select("SELECT * FROM map_location_config WHERE organization_id = #{organizationId} AND is_active = 1 ORDER BY sort_order ASC")
    List<MapLocationConfig> selectByOrganizationId(@Param("organizationId") Long organizationId);
    
    /**
     * 根据名称查询地图位置配置
     */
    @Select("SELECT * FROM map_location_config WHERE name = #{name} AND is_active = 1")
    MapLocationConfig selectByName(@Param("name") String name);
} 